﻿using DoNet.Core;
using DoNet.System.Models;
using System.Linq.Expressions;

namespace DoNet.System.IRepositories
{
    /// <summary>
    /// 
    /// </summary>
    public interface ITokenRepository : IRepository<Token>
    {
        #region 同步方法

        #region 修改
        /// <summary>
        /// 同步更新AccessToken
        /// </summary>
        /// <param name="token"></param>
        /// <param name="accessExpire"></param>
        /// <param name="lastModifyUserId"></param>
        /// <param name="lastModifyTime"></param>
        /// <param name="id"></param>
        /// <returns>执行成功返回true，否则为false。</returns>
        bool Update(string token, int accessExpire, long lastModifyUserId, DateTime lastModifyTime, long id);
        #endregion 修改

        #region 查询
        /// <summary>
        /// 同步获取当前AppId未过期的Token
        /// </summary>
        /// <param name="appId"></param>
        /// <returns></returns>
        Token GetTokenByAppId(string appId);
        /// <summary>
        /// 同步获取当前token或者刷新token
        /// </summary>
        /// <param name="token">当前token或者刷新token</param>
        /// <returns></returns>
        Token GetTokenIsRevoked(string token);
        /// <summary>
        /// 同步根据刷新token获取当前token
        /// </summary>
        /// <param name="refreshToken">刷新token</param>
        /// <returns></returns>
        Token GetTokenByRefreshToken(string refreshToken);
        #endregion 查询

        #endregion 同步方法

        #region 异步方法

        #region 修改
        /// <summary>
        /// 异步更新AccessToken
        /// </summary>
        /// <param name="token"></param>
        /// <param name="accessExpire"></param>
        /// <param name="lastModifyUserId"></param>
        /// <param name="lastModifyTime"></param>
        /// <param name="id"></param>
        /// <returns>执行成功返回true，否则为false。</returns>
        Task<bool> UpdateAsync(string token, int accessExpire, long lastModifyUserId, DateTime lastModifyTime, long id);
        #endregion 修改

        #region 查询
        /// <summary>
        /// 异步获取当前AppId未过期的Token
        /// </summary>
        /// <param name="appId"></param>
        /// <returns></returns>
        Task<Token> GetTokenByAppIdAsync(string appId);
        /// <summary>
        /// 异步获取当前token或者刷新token
        /// </summary>
        /// <param name="token">当前token或者刷新token</param>
        /// <returns></returns>
        Task<Token> GetTokenIsRevokedAsync(string token);
        /// <summary>
        /// 异步根据刷新token获取当前token
        /// </summary>
        /// <param name="refreshToken">刷新token</param>
        /// <returns></returns>
        Task<Token> GetTokenByRefreshTokenAsync(string refreshToken);
        #endregion 查询

        #endregion 异步方法
    }
}
